#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import json
import requests

sys.path.append(
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "imlfapi")
)

from db import EntityTB

apply_graph_id = 1056
# 测试
base_url = "http://localhost:8000/imlf/api/v1/template/%s/apply" % apply_graph_id
# 线上
# base_url = 'http://10.12.3.162:32488/imlf/api/v1/'
headers = {
    # "token": "",
}

# entitys = EntityTB.find(f_type='S')
entitys = EntityTB.find()

entity_ids = [i["id"] for i in entitys]


def apply_template_by_api():
    data = dict(modelIds=entity_ids)
    res = requests.post(base_url, headers=headers, json=data)
    content = json.loads(res.content)
    print(content)
    pass


def main():
    apply_template_by_api()
    # print(entity_ids)
    # 从WindFarmdb wind_farm_info取所有用户列表数据


if __name__ == "__main__":
    main()
